﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Media;

namespace GameJam2012
{
    public class GameController
    {
        LevelManager levelManager;

        public void Initialize()
        {
            levelManager = new LevelManager(this);
            levelManager.Initialize();
            LevelData startLevel1 = new LevelData();
            startLevel1.LoadLevel("levels/start.txt");
            Level firstLevel = new Level(startLevel1);
            PlayerEntity player = new PlayerEntity();
            player.Spawn(firstLevel);
            firstLevel.AddEntity(player);
            levelManager.TrackEntity(player);
            levelManager.PushLevel(firstLevel);

            MediaPlayer.IsRepeating = true;
            MediaPlayer.Play(SnakeGame.SONG);
        }

        public void Update(GameTime gameTime)
        {
            levelManager.Update(gameTime);
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            levelManager.Draw(spriteBatch);
        }
    }
}
